package com.itqf.utils;

import com.itqf.enums.MyEnums;

import java.util.HashMap;

/**
 * 作者：杨超波
 * 时间：2019/12/4  20:42
 * 描述：
 */
public class R extends HashMap<Object,Object> {
    private  int code;
    private String msg;
    private Object data;

    public R(){}

    public R(int code){
        this.put("code",code);
    }

    public R(int code, Object msg,Object data){
        super.put("code",code);
        super.put("msg",msg);
        super.put("data",data);
    }

    public  static R ok(){
        return new R(1);
    }

    public  static R ok(String msg, Object data){
        return new R(1,msg,data);
    }

    public  static R error(){
        return new R(0);
    }
    public  static R error(MyEnums myEnums){
        return new R(myEnums.getCode(),myEnums.getMsg(),null);
    }

    public R put(String key, Object o){
        super.put(key,o);
        return this;
    }
}
